package com.hadoop.mr.sort;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class AllSortDriver {
	public static String NAME_NODE_URL = "hdfs://192.168.186.6:9000";
	
	public static void main(String[] args) throws Exception {
		Configuration conf = new Configuration();
		Job job = Job.getInstance(conf);
		
		job.setJarByClass(AllSortDriver.class);
		job.setMapperClass(AllSortMapper.class);
		job.setReducerClass(AllSortReducer.class);
		
		job.setNumReduceTasks(4);
		job.setPartitionerClass(AllSortPartitioner.class);
		
		job.setMapOutputKeyClass(IntWritable.class);
		job.setMapOutputValueClass(IntWritable.class);
		
		job.setOutputKeyClass(IntWritable.class);
		job.setOutputValueClass(IntWritable.class);
		
		FileInputFormat.setInputPaths(job, new Path(NAME_NODE_URL + "/mr/sort.txt"));
		FileOutputFormat.setOutputPath(job, new Path(NAME_NODE_URL + "/mr/result/sort/"));
		
		job.waitForCompletion(true);
	}
}
